home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10686 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.2 KB

  1. Path: solon.com!not-for-mail
  2. From: makholm@diku.dk (Henning Makholm)
  3. Newsgroups: comp.lang.c,comp.lang.c.moderated
  4. Subject: Re: C coding problem
  5. Date: 19 Mar 1996 06:46:28 -0600
  6. Organization: Department of Computer Science, U of Copenhagen
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4imab4$dt9@solutions.solon.com>
  10. References: <4ianbf$h86@solutions.solon.com>
  11. NNTP-Posting-Host: solutions.solon.com
  12.  
  13. proctor@corp.hp.com (Stephen Proctor) writes:
  14.  
  15. >I am trying to write a *simple* C program and am running into the following
  16. >warning problem shown below.  Why do I get this warning?  
  17.  
  18. >   if (*argv[ii] == '-') option_val = read_options;
  19.  
  20. I'd guess that you've programmed in Pascal before and made a function
  21. of no parameters calles read_options. However, in C you always need
  22. parentheses to express a function call, even when there are no
  23. parameters. What you probably mean is,
  24.  
  25.   if ( ....... ) option_val = read_options();
  26.  
  27.  
  28. In C, (almost) any mention of a function identifier formally produces
  29. a value which is a pointer to a function (and the right argument to
  30. the function-call parentheses is likewise expected to be a pointer to
  31. a function). Since you do not - to the compiler - appear to call your
  32. function pointer, it complains then you try to assign that pointer to
  33. an integer variable, hence the fluff about integer/pointer problems in
  34. the warning.
  35.  
  36. (More than a few of the others who responded had this in mind, I
  37.  think. Why didn't anybody explain this, then? There is this strange
  38.  urge to make oneself stupider than one is when trying to help some
  39.  poor newbie, it be with C or almost any other topic. Why, the general
  40.  attitude ought to be "maybe your problem is this-and-this", rather
  41.  than assume I am a machine and complain about missing information
  42.  with THE canonical C newbie problem blinking there right in my
  43.  face. Sure, I don't claim to be better than others, and I often find
  44.  myself falling into that trap in my work as an instructor. I was
  45.  about to do the same again here but felt sorry for the guy...)
  46.  
  47. [hp newsgrous removed from newsgroups line as this is a general C problem]
  48.  
  49. -- 
  50.  
  51. Henning Makholm - math and CS student - University of Copenhagen
  52. makholm@diku.dk - http://www.diku.dk/students/makholm - fido 2:235/224.92
  53.